/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.ui;

import java.io.IOException;
import nominalitzacions.domain.PasswordDomainController;

/**
 *
 * @author daniel.camacho.rodriguez
 */
public class ChangePasswordViewController {
    private PasswordDomainController PDC;
    private ChangePasswordView mainCPV = null;

    public ChangePasswordViewController(){
        if (mainCPV == null) mainCPV = new ChangePasswordView(this);
        try {
            PDC = new PasswordDomainController();
        } catch (IOException ex) {
            mainCPV.openError(ex.getMessage());
        }
    }

    public void setInvisible() {
        mainCPV.setInvisible();
    }

    public void setVisible() {
        mainCPV.setVisible();
    }

    public boolean verificationPass(String pass){
        return pass.equals(PDC.getPass());
    }

    public void passChangeTo(String newPassword){
        try {
            PDC.changePassTo(newPassword);
        } catch (IOException ex) {
            mainCPV.openError(ex.getMessage());
        }
    }

    public void closeChangePass(){
        mainCPV.setInvisible();
    }

}
